﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace _0812045
{
    public abstract class BaseSprite
    {
        protected Texture2D[] _texture2d;

        public Texture2D[] texture2d
        {
            get { return _texture2d; }
            set
            {
                _texture2d = value;
                _ntexture2d = _texture2d.Length;
            }
        }
        protected int _ntexture2d;

        public int ntexture2d
        {
            get { return _ntexture2d; }
            set { _ntexture2d = value; }
        }

        protected float _x;

        public float x
        {
            get { return _x; }
            set { _x = value; }
        }
        protected float _y;

        public float y
        {
            get { return _y; }
            set { _y = value; }
        }

        protected int _itexture2d;

        protected int itexture2d
        {
            get { return _itexture2d; }
            set { _itexture2d = value; }
        }

        protected bool _isFinish;

        public bool isFinish
        {
            get { return _isFinish; }
            set { _isFinish = value; }
        }
        public void LoadContent(ContentManager theContentManager, string theAssetName)
        {
            _ntexture2d =1;
            _texture2d = new Texture2D[_ntexture2d];
            _itexture2d = 0;
            _texture2d[_itexture2d] = theContentManager.Load<Texture2D>(theAssetName);
            AssetName = theAssetName;
            Size = new Rectangle(0, 0, (int)(_texture2d[_itexture2d].Width * Scale), (int)(_texture2d[_itexture2d].Height * Scale));
        }
        public string AssetName;

        //The Size of the Sprite (with scale applied)
        public Rectangle Size;
        protected float mScale = 1;
        public float Scale
        {
            get { return mScale; }
            set
            {
                mScale = value;
                float viewportHeight = mScale * this.Size.Height;
                //Recalculate the Size of the Sprite with the new scale
                Size = new Rectangle(0, 0, (int)(_texture2d[_itexture2d].Width * Scale), (int)(_texture2d[_itexture2d].Height * Scale));
            }
        }

        public virtual void Update(GameTime gameTime)
        {
        }
        public virtual void Update(GameTime theGameTime, Vector2 theSpeed, Vector2 theDirection) 
        { 
        }
        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
        }
    }
}
